
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
babel-plugin-minify-mangle-names
Advanced tools
The babel-plugin-minify-mangle-names package is a Babel plugin that minifies JavaScript code by mangling variable and function names. This helps reduce the size of the output file, which can improve load times and performance for web applications.
Mangle Variable Names
This feature renames variables and function names to shorter versions, reducing the overall size of the code.
const babel = require('@babel/core');
const code = 'function add(a, b) { return a + b; }';
const output = babel.transformSync(code, { plugins: ['babel-plugin-minify-mangle-names'] });
console.log(output.code); // Output: function a(a,b){return a+b}
Mangle Function Names
This feature renames function names to shorter versions, which helps in reducing the size of the code.
const babel = require('@babel/core');
const code = 'function multiply(x, y) { return x * y; }';
const output = babel.transformSync(code, { plugins: ['babel-plugin-minify-mangle-names'] });
console.log(output.code); // Output: function a(a,b){return a*b}
UglifyJS is a JavaScript parser, minifier, compressor, and beautifier toolkit. It provides more comprehensive minification options compared to babel-plugin-minify-mangle-names, including dead code removal and advanced optimizations.
Terser is a JavaScript parser and mangler/compressor toolkit for ES6+. It is a fork of UglifyJS and offers similar functionalities with better support for modern JavaScript syntax. Terser is often used in build tools like Webpack for minifying JavaScript code.
Babel Minify is a Babel plugin that minifies JavaScript code. It includes a variety of minification plugins, including babel-plugin-minify-mangle-names. It provides a more integrated solution for Babel users who want to minify their code as part of the Babel transformation process.
Context- and scope- aware variable renaming.
In
var globalVariableName = 42;
function foo() {
var longLocalVariableName = 1;
if (longLocalVariableName) {
console.log(longLocalVariableName);
}
}
Out
var globalVariableName = 42;
function foo() {
var a = 1;
if (a) {
console.log(a);
}
}
$ npm install babel-plugin-minify-mangle-names
.babelrc
(Recommended).babelrc
// without options
{
"plugins": ["minify-mangle-names"]
}
// with options
{
"plugins": ["minify-mangle-names", { "blacklist": { "foo": true, "bar": true} }]
}
$ babel --plugins minify-mangle-names script.js
require("babel-core").transform("code", {
plugins: ["minify-mangle-names"]
});
blacklist
- A plain JS Object with keys as identifier names and values indicating whether to excludeeval
- mangle identifiers in scopes accessible by evalkeepFnName
- prevent mangler from altering function names. Useful for code depending on fn.name
FAQs
Context- and scope- aware variable renaming.
The npm package babel-plugin-minify-mangle-names receives a total of 256,991 weekly downloads. As such, babel-plugin-minify-mangle-names popularity was classified as popular.
We found that babel-plugin-minify-mangle-names demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.